package com.credit.management.system.generator.dao;

import com.credit.management.system.model.ContractSub;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface ContractSubMapper {
    @Delete({
        "delete from contract_sub",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into contract_sub (id, contract_id, ",
        "sum, repayment_date, ",
        "state)",
        "values (#{id,jdbcType=BIGINT}, #{contractId,jdbcType=BIGINT}, ",
        "#{sum,jdbcType=BIGINT}, #{repaymentDate,jdbcType=TIME}, ",
        "#{state,jdbcType=BIGINT})"
    })
    int insert(ContractSub record);

    int insertSelective(ContractSub record);

    @Select({
        "select",
        "id, contract_id, sum, repayment_date, state",
        "from contract_sub",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.credit.management.system.generator.dao.ContractSubMapper.BaseResultMap")
    ContractSub selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ContractSub record);

    @Update({
        "update contract_sub",
        "set contract_id = #{contractId,jdbcType=BIGINT},",
          "sum = #{sum,jdbcType=BIGINT},",
          "repayment_date = #{repaymentDate,jdbcType=TIME},",
          "state = #{state,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(ContractSub record);
}